<template>
    <div>
      <basic-container>
        <avue-crud ref="crud"
                   :page.sync="page"
                   :data="buyerList"
                   :table-loading="tableLoading"
                   :option="tableOption"
                   @on-load="getCustomerList"
                   @search-change="searchChange"
                   @refresh-change="refreshChange">
        </avue-crud>
      </basic-container>
    </div>
</template>

<script>
    import Request from "../request.js";
    import {
      tableOption
    } from '@/const/crud/pds/merchant/customer'
    export default {
        data: function(){
            return {
                page: {
                  total: 0, // 总页数
                  pageNo: 1, // 当前页数
                  pageSize: 20 // 每页显示多少条
                },
                layout:"total, sizes, prev, pager, next, jumper",
                request: new Request(),
                editValue: {},
                dialogFormVisible: false,
                buyerList: [],
                inquire:{
                    nickName: ""
                },
              tableOption:tableOption,
              tableLoading:false
            }
        },
        watch:{
        },
        created(){

        },
        methods:{

            /**
             * 刷新回调
             */
            refreshChange(info) {
                this.getCustomerList(this.page, this.filterForm(info.searchForm));
            },
            searchChange(form, done) {
                this.getCustomerList(this.page, form);
                done();
            },
            // 查询用户列表
            getCustomerList(page,params={}) {
                params.pageSize = page.pageSize;
                params.pageNo = page.currentPage;
                this.request.getCustomerList(params).then(res => {
                    if (res.code === 200) {
                        this.buyerList = res.ext.list;
                        this.page.total = res.ext.count;
                        this.$message.success("列表刷新成功")
                    }else{
                        this.$message.warning("未查询到用户列表：" + res.msg)
                    }
                })
            },
        }
    }
</script>

<style scoped lang="scss">
    .top{
        display: flex;
        background-color: white;
        padding: 10px;
        margin-bottom: 20px;
    }
    .top>div{
       margin-left: 50px;
       line-height: 40px;
     }
    .top>div .userName{
      margin-left: 10px;
    }
    .page-box{
        background-color: white;
        display: flex;
        justify-content: space-between;
    }
</style>
